package Models;

import DB.DBLocation;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
// #[regen=yes,id=DCE.B0B1B268-A6B6-41A1-C3DC-388D5F062B39]
// </editor-fold> 
public class Customer extends DB.RowAbstract
{
	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.A9579A8A-F12D-2C1F-8D60-78F69375767A]
	// </editor-fold> 
	private int customerNo;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.5F27E917-CF5C-4926-7AFC-058620135490]
	// </editor-fold> 
	private String name;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.3C434944-EFDB-9FB2-D396-C84A040E5609]
	// </editor-fold> 
	private String address;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.9972E6B8-CBEF-9440-E2BC-879F8B60056B]
	// </editor-fold> 
	private int zipCode;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.C11175B9-C8B1-5CD1-7011-3334665D789F]
	// </editor-fold> 
	private String city;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
	// #[regen=yes,id=DCE.57535BA8-17A3-1CCA-3BBA-BFB860519CD1]
	// </editor-fold>
	private int cvr;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,id=DCE.6ECFE1C7-0D57-8F33-5F1E-9B3A27A0A821]
	// </editor-fold> 
	private int phoneNo;

	private ArrayList<Location> locations;

	// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
	// #[regen=yes,id=DCE.27FAF651-8972-BD7E-8D5D-95F28222C511]
	// </editor-fold>
	public Customer ()
	{}

	public void importData(ResultSet data) throws SQLException
	{
		this.setCustomerNo(data.getInt("customerNo"));
		this.setName(data.getString("name"));
		this.setAddress(data.getString("address"));
		this.setZipCode(data.getInt("zipCode"));
		this.setCity(data.getString("city"));
		this.setCvr(data.getInt("cvr"));
		this.setPhoneNo(data.getInt("phoneNo"));
		this.fetchDependentData();
	}

	private void fetchDependentData()
	{
		DBLocation dbl = new DBLocation();
		this.setLocations(dbl.fetchAll("customer = "+customerNo, "zipCode ASC", 0));
	}

	public static String[] getSearchColumns()
	{
		return new String[] { "customerNo", "name", "address", "zipCode", "city", "cvr", "phoneNo" };
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.9F7E4F7A-C547-7F24-B011-23059F0D3C33]
	// </editor-fold> 
	public String getAddress () {
		return address;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.3B0A5D04-0986-DA40-F363-CA7D43671932]
	// </editor-fold> 
	public void setAddress (String val) {
		address = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.CCDC64B4-F3E7-4B38-C61E-A6A73DE15275]
	// </editor-fold> 
	public String getCity () {
		return city;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.23A085F6-CA14-D00A-0727-F3F877FBE074]
	// </editor-fold> 
	public void setCity (String val) {
		city = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
	// #[regen=yes,regenBody=yes,id=DCE.364F94CD-C17A-A1C6-DCD6-0EAF99705880]
	// </editor-fold>
	public int getCustomerNo () {
		return customerNo;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker ">
	// #[regen=yes,regenBody=yes,id=DCE.2A050A8B-28C4-831E-6EA1-53B9A807F14B]
	// </editor-fold>
	public void setCustomerNo (int val) {
		customerNo = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.6036996C-9C46-95B6-4E67-1AD83B526959]
	// </editor-fold> 
	public int getCvr () {
		return cvr;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.E9EBCD96-0D00-A96D-8183-8845209E2F5E]
	// </editor-fold> 
	public void setCvr (int val) {
		cvr = val;
	}

	public ArrayList<Location> getLocations()
	{
		return locations;
	}

	public void setLocations(ArrayList<Location> locations)
	{
		this.locations = locations;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.4BB87FBE-40D0-CE7A-41E1-4FF352B5840C]
	// </editor-fold> 
	public String getName () {
		return name;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.8CAFFC89-31F5-81AB-457E-F22F31D36298]
	// </editor-fold> 
	public void setName (String val) {
		name = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.3A4ED67C-04B9-FA98-C5E1-1908307751FB]
	// </editor-fold> 
	public int getPhoneNo () {
		return phoneNo;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.CC3FF0E3-AE00-1DF0-AFD6-9CF276259F10]
	// </editor-fold> 
	public void setPhoneNo (int val) {
		phoneNo = val;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.92A2E2B1-CFE2-FBED-F834-6C9C45470613]
	// </editor-fold> 
	public int getZipCode () {
		return zipCode;
	}

	// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
	// #[regen=yes,regenBody=yes,id=DCE.04026A7C-E895-A84B-48E1-A2A53945DB98]
	// </editor-fold> 
	public void setZipCode (int val) {
		zipCode = val;
	}
}